package com.ap.core.dao.impl;

import com.ap.core.dao.AbstractAPCoreBaseJpaDao;
import com.ap.core.dao.QuickPayDeliveryAddressDao;
import com.ap.core.domain.OrderPaymentRefund;
import com.ap.core.domain.QuickPayDeliveryAddress;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * User: Ranjit.Singh
 * Jpa Implementation class for {@link com.ap.core.dao.QuickPayDeliveryAddressDao}
 */
public class JpaQuickPayDeliveryAddressDao extends AbstractAPCoreBaseJpaDao<QuickPayDeliveryAddress, Long> implements QuickPayDeliveryAddressDao {

    @Override
    public QuickPayDeliveryAddress findById(Long primaryKey) {
        return findById(QuickPayDeliveryAddress.class, primaryKey);
    }

    @Override
    public QuickPayDeliveryAddress getReadOnlyQuickPayDeliveryAddressByAPTransactionId(String apTransactionId) {
        final Criteria criteria = getSession().createCriteria(QuickPayDeliveryAddress.class);
        criteria.add(Restrictions.eq("apTransactionId", apTransactionId));
        criteria.setReadOnly(true);
        return (QuickPayDeliveryAddress)criteria.uniqueResult();
    }
}
